﻿using System.Globalization;
using System.Reflection;
using Windows.UI.Xaml.Media;

namespace XamlInspector.Model.Properties
{
    public class XamlBrushProperty : XamlProperty
    {
        public XamlBrushProperty(PropertyInfo propertyInfo, object element, string category = "Common")
            : base(propertyInfo, element, category)
        {
        }

        public Brush Brush
        {
            get { return PropertyInfo.GetValue(Element) as Brush; }
            set { PropertyInfo.SetValue(Element, value); }
        }

        public string BrushText
        {
            get
            {
                var solidBrush = Brush as SolidColorBrush;
                if (solidBrush != null)
                {
                    var color = solidBrush.Color;
                    color.ToString(CultureInfo.InvariantCulture);
                }
                
                return string.Empty;
            }
        }
    }
}
